"""
Case Type   : 系统内部使用工具
Case Name   : 使用gs_probackup工具gs_probackup的版本信息然后退出
Create At   : 2021/01/15
Owner       : opentestcase015
Description :
    1.使用gs_probackup工具打印版本信息
Expect      :
    1.使用gs_probackup工具打印版本信息成功
History     :
    modified by l1azzzy at 2024/12/5:优化提示信息，以及逻辑，适配7.0.0-RC1版本
"""

import unittest

from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger
from yat.test import Node
from yat.test import macro

LOG = Logger()


class LogicalReplication(unittest.TestCase):
    def setUp(self):
        LOG.info('----------------this is setup-----------------------')
        LOG.info(
            '---Opengauss_Function_Tools_Gs_Probackup_Case0001开始执行-----')
        self.constant = Constant()
        self.user_node = Node('dbuser')
        self.env_path = macro.DB_ENV_PATH
        self.user_node = Node('PrimaryDbUser')

    def test_system_internal_tools(self):
        LOG.info(
            '---------------------查看版本信息-------------------------')
        excute_cmd = f'''
                    source {self.env_path};
                    gs_probackup -V;
                    '''
        LOG.info(excute_cmd)
        msg = self.user_node.sh(excute_cmd).result()
        LOG.info(msg)
        self.assertIn(self.constant.opengauss, msg)

    def tearDown(self):
        LOG.info('----------------this is tearDown-----------------------')
        # 无需清理环境
        LOG.info(
            '-----Opengauss_Function_Tools_Gs_Probackup_Case0001执行完成---')
